package com.cloudptt.api.comm;

import com.cloudptt.api.models.VersionInfo;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

public class CommInfo {
	private Context ctx = null;
	public CommInfo(Context ctx)
	{
		this.ctx = ctx;
	}
	
	public VersionInfo getVersionInfo() {
	    try {
	        PackageManager manager = ctx.getPackageManager();
	        PackageInfo info = manager.getPackageInfo(ctx.getPackageName(), 0);
	        VersionInfo versionInfo = new VersionInfo(info.versionName,info.versionCode);
	        return versionInfo;
	    } catch (Exception e) {
	        e.printStackTrace();
	        return null;
	    }
	}
}
